package com.ebupt.dbmodule

import android.util.Log
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.paging.*
import com.alibaba.android.arouter.facade.annotation.Route
import com.ebupt.common.base.BaseActivity
import com.ebupt.dbmodule.databinding.ActivityDbBinding
import com.ebupt.service.Navigation
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import org.koin.androidx.viewmodel.ext.android.viewModel
import retrofit2.http.Path

@Route(path = Navigation.LOGIN_URL)
class DBActivity:BaseActivity<ActivityDbBinding>() {

    private val dbviewmode by viewModel<DBViewModel>()

    override fun getLayoutId(): Int = R.layout.activity_db


    override fun initData() {
        super.initData()
        viewDataBinding.vm = dbviewmode

        dbviewmode.userList.observe(this, Observer {
            if(it!=null&&it.size!=0){
                for (user in it){
                    Log.e("DB",user.toString())
                }
            }

            Log.e("DB","当前为空")

        })

       var adapter = AppUserAdapter()

        viewDataBinding.recycleview.adapter = adapter
        lifecycleScope.launch {
            dbviewmode.flowDataSource.collect {
                adapter.submitData(it)
            }
        }
    }









}